<template>
  <div id="app" class="app-page">
    <root name="unbatchInspection_skip">
      <safe-header
        v-bind="{
          title: '待检任务列表',
          isBack: true,
          backIconColor: '#fff',
          fixedTop: true,
        }"
      />
      <div>
        <v-container>
          <!-- <v-row>
            <v-col :cols="12" class="pb-0">
              <v-text-field
                autofocus
                clearable
                filled
                :prepend-inner-icon="mdiCreditCardScan"
                class="my-0 inputPlaceholder"
                @keydown.13="acceptRecordCodeSearch"
                dense
                hide-details
                v-model="acceptRecordCode"
                placeholder="收货单号"
              ></v-text-field>
            </v-col>
          </v-row> -->
          <v-row>
            <v-col :cols="12" class="pb-0">
              <v-text-field
                dense
                :prepend-inner-icon="mdiMagnify"
                v-model="keyWords"
                solo
                hide-details
                placeholder="请输入订单号或供应商进行查询"
                @input="chooseConditions"
                @keydown.13="taskCodeSearch"
                style="font-size: 14px"
              ></v-text-field>
            </v-col>
          </v-row>
        </v-container>
        <v-container width:80%>
          <v-card
            class="mx-auto my-2 list_card"
            max-width="374"
            v-for="item in warehouseOrderList"
            :key="item.code"
            outlined
            @click="asnCodeSearch(item)"
            style="board: thin solid #cacbcc"
          >
            <v-card-title class="pb-3 card-title">
              <v-row>
                <v-col cols="7" class="py-0 d-flex align-center">
                  {{ item.billNo }}
                  <span class="ms-2 card-tag" style>
                    {{
                    item.qcState == -1
                    ? "未检"
                    : item.qcState == 0
                    ? "待检"
                    : item.qcState == 1
                    ? "合格"
                    : item.qcState == 2
                    ? "不合格"
                    : item.qcState == 3
                    ? "已检"
                    : ""
                    }}
                  </span>
                </v-col>
                <v-col cols="3" class="py-0 d-flex align-center">
                  <!-- <span class="ms-2 card-tag" style>
                    <v-btn
                      style="
                        background-color: #627aec;
                        height: 100%;
                        border-radius: 5px;
                        margin-left: 50px;
                        color: #fff;

                      "
                      @click.stop="allQualified(item)"
                    >全部合格</v-btn>
                  </span> -->
                </v-col>
                <v-col cols="2" class="py-0 d-flex align-center">
                  <v-icon color="#CACBCC" style="margin-left:30px">{{ svgpath }}</v-icon>
                </v-col>
                <!-- <v-col
                  class="text-right py-0 pr-0 d-flex align-center justify-end"
                >
                 </v-col
                >-->
              </v-row>
            </v-card-title>

            <v-divider class="my-0 card-sp-line"></v-divider>

            <v-card-text>
            
              <v-row>
                <v-col cols="3" class="py-1" style="color: #999999">采购单号</v-col>
                <v-col
                  class="ms-2 py-1 text-right"
                  style="font-size: 0.75rem; color: #666666"
                >{{ item.requestBuyBillNo }}</v-col>
              </v-row>
              <v-row>
                <v-col cols="3" class="py-1" style="color: #999999">供应商</v-col>
                <v-col
                  class="ms-2 py-1 text-right"
                  style="font-size: 0.75rem; color: #666666"
                >{{ item.supplierName }}</v-col>
              </v-row>
              <v-row>
                <v-col cols="3" class="py-1" style="color: #999999">制单人</v-col>
                <v-col
                  class="ms-2 py-1 text-right"
                  style="font-size: 0.75rem; color: #666666"
                >{{ item.createUserName }}</v-col>
              </v-row>
                <v-row class="d-flex flex-row justify-space-between">
                <v-col cols="3" class="py-1 card-lable">创建时间</v-col>
                <v-col class="ms-2 py-1 text-right card-value">{{ item.createTime }}</v-col>
              </v-row>
            </v-card-text>
          </v-card>
        </v-container>
      </div>
      <!-- <v-dialog v-model="isQBHG" min-width="344">
        <v-card class="mx-auto" max-width="344">
          <v-card-title class="text-h5">提 示</v-card-title>
          <v-card-text>
            <p></p>
            <div class="text--primary">确定已经全部合格</div>
          </v-card-text>
          <v-card-actions>
            <v-spacer></v-spacer>
            <v-btn class="ma-2" text color="indigo" @click="isQBHG = false">取消</v-btn>
            <v-btn class="ma-2" text color="teal" @click="isConfirm()">确认</v-btn>
          </v-card-actions>
        </v-card>
      </v-dialog>-->
    </root>
  </div>
</template>

<script>
import SafeHeader from "../../components/safeHeader_wms";
import Storage from "@/utils/storage.js";
import wms from "../../utils/http.js";
import { apiList } from "@/static/apiList";
import { mdiChevronRight, mdiMagnify, mdiCreditCardScan } from "@mdi/js";
import Root from "@/components/Root.vue";
// import qs from "qs";

export default {
  name: "unbatchInspection_skip",
  components: {
    SafeHeader,
    Root
  },
  data() {
    return {
      svgpath: mdiChevronRight,
      mdiMagnify: mdiMagnify,
      value: "",
      billNo: "",
      keyWords: "",
      acceptRecordCode: "",
      // states: [
      //   { name: "NCONV1001841201612", id: "NCONV1001841201612" },
      //   { name: "NCONV1001841201613", id: "NCONV1001841201613" },
      //   { name: "NCONV1001841201614", id: "NCONV1001841201614" },
      //   { name: "NCONV1001841201615", id: "NCONV1001841201615" },
      //   { name: "NCONV1001841201616", id: "NCONV1001841201616" },
      // ],
      infoList: [],
      mdiCreditCardScan: mdiCreditCardScan,
      warehouseOrderList: []
      // // 全部收货确认框标识
      // isQBHG: false,
      // // 全部收货方法执行标识
      // isallQualified: false,
      // // 全部收货过度数据
      // ShItem: null
    };
  },
  computed: {},
  methods: {
    //搜索
    taskCodeSearch() {
      let params = {
        // wareId: Storage.getObject("loginConfig").wareIds[0],
        // asnState: 0,
        // insertType: 0,
        // asnType: 24,
        keyWords: this.keyWords
      };

      wms.get({ url: "/asn/masters/qcList", data: params }).then(res => {
        console.log(res);
        this.infoList = res.data.data.list;
        let qcStates = apiList.qcStates;
        this.infoList.forEach(item => {
          qcStates.forEach(val => {
            if (item.qcState == val.value) {
              item.qcState = val.label;
            }
          });
        });
        this.warehouseOrderList = this.infoList;
      });
    },
    //搜索
    acceptRecordCodeSearch() {
      if (!this.acceptRecordCode) {
        this.$root.api.api.toast({
          msg: "收货单号为空",
          location: "middle",
        });
        return false;
      }
      let tagData = this.acceptRecordCode.split("---");
      this.acceptRecordCode = tagData[0];
      // 进入出库单列表
      if (window.navigator.userAgent.toLowerCase().includes("apicloud")) {
        window.api.openWin({
          name: "unbatchInspection_skip",
          url: "./unbatchInspection_skip.html",
          pageParam: {
            acceptRecordCode: this.acceptRecordCode
          }
        });
      } else {
        this.$root.api.api.openWin({
          name: "unbatchInspection_skip",
          url: "./unbatchInspection_skip.html",
          pageParam: {
            acceptRecordCode: this.acceptRecordCode
          }
        });
      }
    },
    // 确认全部合格
    isConfirm() {
      // 关闭弹框
      this.isQBHG = false;
      // 执行全部合格方法
      this.isallQualified = true;
      this.allQualified(this.ShItem);
    },
    // 全部合格按钮
    allQualified(item) {
      console.log(item);
      // this.billNo = item.billNo
      if (confirm("确认全部合格")) {
        let params = {
          billCode: item.billNo
        };
        wms.post({ url: "/qc/records/submit", data: params }).then(res => {
          console.log(res);
          if (res.status == 200) {
            // alert("提交成功");
            //刷新页面
            window.location.reload();
          } else {
            alert(res.msg);
          }
        });
      } else {
        window.location.reload();
      }
    },
    //   customFilter(item, queryText) {
    //     // 选择项   输入的查询字段   显示值(name)
    //     const textOne = item.name.toLowerCase();
    //     const textTwo = item.abbr.toLowerCase();
    //     const searchText = queryText.toLowerCase();
    //     return (
    //       textOne.indexOf(searchText) > -1 || textTwo.indexOf(searchText) > -1
    //     );
    //   },
    // 当前选中值发生变化时
    chooseConditions(text) {
      // console.log(text);
      // 更改下方列表
      this.warehouseOrderList.filter(item => {
        console.log(item);
        if (item.supplierName.includes(text)) {
          return item.supplierName;
        }
      });
    },
    // 获取列表
    asnCodeSearch(item) {
      console.log(`----------------------------------------${item.billNo}`);
      if (window.navigator.userAgent.toLowerCase().includes("apicloud")) {
        window.api.openWin({
          name: "unbatchInspection_skip",
          url: "./unbatchInspection_skip.html",
          pageParam: {
            asnCode: item.billNo
          }
        });
      } else {
        // this.$root.api.api.sendEvent({
        //   name: "unbatchInspection_skip",
        //   extra: {
        //     billNo: item.billNo,
        //   },
        // });
        this.$root.api.api.openWin({
          name: "unbatchInspection_skip",
          url: "./unbatchInspection_skip.html",
          pageParam: {
            billCode: item.billNo
          }
        });
      }
    }
  },
  mounted() {
    let params = {
      wareId: Storage.getObject("loginConfig").wareIds[0],
      asnState: 0,
      insertType: 0,
      asnType: 24
    };

    wms.get({ url: "/asn/masters/qcList", data: { params } }).then(res => {
      console.log(res);
      this.infoList = res.data.data.list;
      let qcStates = apiList.qcStates;
      this.infoList.forEach(item => {
        qcStates.forEach(val => {
          if (item.qcStates == val.value) {
            item.qcState = val.label;
          }
        });
      });
      this.warehouseOrderList = this.infoList;
    });
  }
};
</script>

<style lang="scss" scoped>
.v-btn:not(.v-btn--round).v-size--default {
  padding: 0 !important;
}
::v-deep .v-application--is-ltr .ms-2 {
  // margin-left: 1px !important;
}
.col-xl,
.col-xl-auto,
.col-xl-12,
.col-xl-11,
.col-xl-10,
.col-xl-9,
.col-xl-8,
.col-xl-7,
.col-xl-6,
.col-xl-5,
.col-xl-4,
.col-xl-3,
.col-xl-2,
.col-xl-1,
.col-lg,
.col-lg-auto,
.col-lg-12,
.col-lg-11,
.col-lg-10,
.col-lg-9,
.col-lg-8,
.col-lg-7,
.col-lg-6,
.col-lg-5,
.col-lg-4,
.col-lg-3,
.col-lg-2,
.col-lg-1,
.col-md,
.col-md-auto,
.col-md-12,
.col-md-11,
.col-md-10,
.col-md-9,
.col-md-8,
.col-md-7,
.col-md-6,
.col-md-5,
.col-md-4,
.col-md-3,
.col-md-2,
.col-md-1,
.col-sm,
.col-sm-auto,
.col-sm-12,
.col-sm-11,
.col-sm-10,
.col-sm-9,
.col-sm-8,
.col-sm-7,
.col-sm-6,
.col-sm-5,
.col-sm-4,
.col-sm-3,
.col-sm-2,
.col-sm-1,
.col,
.col-auto,
.col-12,
.col-11,
.col-10,
.col-9,
.col-8,
.col-7,
.col-6,
.col-5,
.col-4,
.col-3,
.col-2,
.col-1 {
  padding: 7px;
}
</style>
